<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>继承</title>
</head>
<body>
    <script>
        class Animal{
            constructor(name){
                this._name = name;
            }
            get name(){
                return this._name;
            }
            set name(_name){
                this._name = _name;
            }
            intro(){
                console.log(`大家好，我是${this._name}`);
            }
        }
        class Dog extends Animal{
            shout(){
                console.log("汪汪汪~~~");
            }
        }
        class Cat extends Animal{

        }
        let dog = new Dog("旺旺");
        dog.intro();
        dog.shout();
        let cat = new Cat("喵喵");
        cat.intro();
        // cat.shout();

        class Phone{
            constructor(size,color){
                this._size = size;
                this._color = color;
            }
            get size(){
                return this._size;
            }
            set size(_size){
                this._size = size;
            }
            get color(){
                return this._color;
            }
            set color(_color){
                this._color = color;
            }
        }
        class Android extends Phone{
            unlock(){
                console.log("指纹解锁");
            }
        }
        class IPhone extends Phone{

        }
        class HuaWei extends Android{
            constructor(cpu,size,color){
                // super：指向父类的对象，super()表示调用父类的构造函数
                // 如果子类没有写构造函数，它默认有一个构造函数，并自动调用父类的构造函数
                // 如果在子类中将构造函数写出来，那么必须手动编写super()调用父类的构造函数
                super(size,color);
                this._cpu = cpu;
            }
            get cpu(){
                return this._cpu;
            }
        }
        class XiaoMi extends Android{

        }
        let mate40 = new HuaWei("麒麟芯片","6寸","黑色");
        console.log(mate40.color,mate40.size,mate40.cpu);
        mate40.unlock();
        console.log(parseInt(Math.random() * 3));
      
    </script>
</body>
</html>